#{extends 'main.html' /}
<div class="page-group">
    <div class="page page-current" id="user-index">
        <section class="user_index content scroll_y">
            <div class="user_tit">
                <div class="tit">
                    <img src="/public/images/head.jpg">
                    <h3><a href="#">${user?.realName}</a></h3>
                    <p>${campusName}</p>
                </div>
            </div>
            <div class="list-block">
                <ul>
                    <a href="/user/userInfo">
                        <li class="item-content">
                            <div class="item-inner">
                                <div class="item-title"><span>业主信息 </span></div>
                                <div class="item-after"><em></em><i class="icon icon-right"></i></div>
                            </div>
                        </li>
                    </a>
                    <a href="/bankcard/index">
                        <li class="item-content">
                            <div class="item-inner">
                                <div class="item-title"><span>绑定银行卡 </span></div>
                                <div class="item-after"><i class="icon icon-right"></i></div>
                            </div>
                        </li>
                    </a>
                    <a href="/issue/repairList">
                        <li class="item-content">
                            <div class="item-inner">
                                <div class="item-title"><span>我的报修记录 </span></div>
                                <div class="item-after"><em></em><i class="icon icon-right"></i></div>
                            </div>
                        </li>
                    </a>
                    <a href="/issue/publicRepairList">
                        <li class="item-content">
                            <div class="item-inner">
                                <div class="item-title"><span>公共区域报修记录 </span></div>
                                <div class="item-after"><i class="icon icon-right"></i></div>
                            </div>
                        </li>
                    </a>
                    <a href="/payment/index">
                        <li class="item-content">
                            <div class="item-inner">
                                <div class="item-title"><span>我的缴费记录 </span></div>
                                <div class="item-after"><em></em><i class="icon icon-right"></i></div>
                            </div>
                        </li>
                    </a>
                </ul>
                <ul>
                    <a href="/user/contact">
                        <li class="item-content">
                            <div class="item-inner">
                                <div class="item-title"><span>联系客服 </span></div>
                                <div class="item-after"><i class="icon icon-right"></i></div>
                            </div>
                        </li>
                    </a>
                </ul>
            </div>
        </section>
    #{include 'weixin/footer.html'/}
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $.init();
        var error="${flash['error']}";
        if(error) $.toast(error);
        $(document).on("pageInit", function(e, pageId, $page) {
            if(pageId == "user-userInfo") {
                $.showPreloader();
                $.getJSON("/user/getUser", null,
                        function (data) {
                            $.hidePreloader();
                            $("#realName").val(data.realName);
                            $("#phone").val(data.phone);
                            $("#idCard").val(data.idCard);
                            $("#gender").val(data.gender);
                            $("#age").val(data.age);
                        }
                )
                $(document).off("click", "#user-button").on("click", "#user-button", function () {
                    if($("#age").val() != "" && isNaN(parseInt($("#age").val()))){
                        $.toast("年龄只能是数字");
                        return;
                    }
                    $.showPreloader();
                    $.getJSON("/user/saveUser", {
                                realName: $("#realName").val(),
                                phone: $("#phone").val(),
                                idCard: $("#idCard").val(),
                                gender: $("#gender").val(),
                                age: $("#age").val()
                            },
                            function (data) {
                                $.hidePreloader();
                                if (data.success) {
                                    $.router.back();
                                } else {
                                    $.toast(data.msg);
                                }
                            }
                    )
                });
            }
        });
    })
</script>